home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Standard question - pointer initialization
- Date: 14 Mar 1996 01:44:13 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar13184413@qcd.lanl.gov>
- References: <4hk9un$906@hammer.msfc.nasa.gov> <4hl6rr$nde@news.xs4all.nl>
- <313E6028.1C19@ix.netcom.com> <4hnpsl$g8c@hacgate2.hac.com>
- <4hq9hsINN998@keats.ugrad.cs.ubc.ca> <4i7cgn$5da@baygull.rtd.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: collins@RTD.COM's message of 13 Mar 1996 20:51:35 GMT
-
- In article <4i7cgn$5da@baygull.rtd.com>
- collins@RTD.COM (Ronald Collins) writes:
- <snip>
- RC: : Also note that NULL is just a macro that stands for the value zero (often
- RC: : accompanied by a cast to void *). In assigning default initialization values to
- RC: : static variables, the compiler couldn't care less that there is a pre-processor
- RC: : macro called NULL. NULL can never be anything other than zero in a
- RC: : standard-conforming implementation of the C language.
- RC:
- RC: This may be true on _your_ implementation, but nothing in the standard
- RC: requires the NULL value to be numerically 0.
- RC:
- RC: Please read the FAQ before posting on the subject again.
-
- Confusion reigns!
-
- NULL is a macro which is defined in a number of standard headers. It
- is guaranteed to be an integral constant (roughly, compile time
- integral constant which does not depend on floating ot pointer
- arithmetic) with the value 0; or such a quantity cast to (void*).
-
- Thus it could be 0, (1-1), (void*)0, __builtin_null (with a previous
- enum __builtin_tag { __builtin_null }; explicit or assumed), or an
- infinity of other forms. However, informally, all of these are zeros.
-
- In a context where the compiler _knows_ that a pointer is required,
- the compiler shall automatically converted all integral constant zeros
- to a null pointer. The representation of this null pointer may
- actually depend on its type, and has no relation to zero. This is what
- the FAQ file was trying to explain.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-